package cn.zebra.dev.admin.module.shop.controller;

import cn.zebra.dev.admin.module.login.SecurityAdminService;
import cn.zebra.dev.admin.module.shop.vo.AdminApplyVO;
import cn.zebra.dev.common.restful.Result;
import cn.zebra.dev.other.module.shopApply.entity.ShopApplyEntity;
import cn.zebra.dev.other.module.shopApply.service.ShopApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author feifeijunxin
 * @Date 2020/5/12 10:51
 * @Version 1.0
 */
@Api(tags = "店铺审核")
@RestController
@RequestMapping("/shop/apply")
public class ShopApplyController {

    @Autowired
    private ShopApplyService shopApplyService;

    @Autowired
    private SecurityAdminService securityAdminService;

    @PostMapping("/update/{id}")
    @ApiOperation("店铺审核")
    public Result save(@PathVariable Long id, @Valid @RequestBody AdminApplyVO vo) {
        ShopApplyEntity entity = new ShopApplyEntity();
        BeanUtils.copyProperties(vo, entity);
        entity.setAdminId(securityAdminService.getId());
        if (!shopApplyService.update(entity, "id={0}", id)) {
            return Result.success("操作失败!");
        }
        return Result.success("操作成功!");
    }

}
